package main

import "fmt"

/*
成功：
	包裹断言值 i 的动态值 的 一个复制的 T值
*/
type MyWriter interface {
	myWrite(buf []byte) (int, error)
}

type DummyWriter struct {
}

func (DummyWriter) myWrite(buf []byte) (int, error) {
	return len(buf), nil
}

func main() {

	var x interface{} = DummyWriter{}
	var y interface{} = "abc"
	var w MyWriter
	var ok bool

	w, ok = x.(MyWriter) // 断言成功，x 的动态值为 DummyWriter{}
	fmt.Printf("%T, %v\n", w, ok)

	x, ok = w.(interface{})

	fmt.Printf("%T, %v\n", x, ok)

	w, ok = y.(MyWriter)
	fmt.Printf("%T, %v\n", w, ok)

}

/*
main.DummyWriter, true
main.DummyWriter, true
<nil>, false
*/
